package com.wjb.xietong.server.topic;

import org.json.JSONObject;

import com.wjb.xietong.server.BaseResponseDataParse;
import com.wjb.xietong.server.HeaderInfoResponse;
import com.wjb.xietong.util.IDs;
import com.wjb.xietong.util.LogD;

public class MessageNotifyResponse extends BaseResponseDataParse {
	private static MessageNotifyResponse instance = null;
	private HeaderInfoResponse headerInfo = null;

	private int my_send = 0;
	private int reply_me = 0;
	private int my_reply = 0;
	private int all_retopic_count = 0;

	private MessageNotifyResponse() {

	}

	public static synchronized MessageNotifyResponse instance() {
		if (null == instance) {
			instance = new MessageNotifyResponse();
		}
		return instance;
	}

	@Override
	public void initData() {
		this.headerInfo = null;
		this.my_send = 0;
		this.reply_me = 0;
		this.my_reply = 0;
		this.all_retopic_count = 0;
	}

	@Override
	public boolean parseJsonObj(JSONObject response) {
		initData();

		if (null == response) {
			LogD.output("Exception: response is null");
			return false;
		}

		if (!checkRespCode(response)) {
			headerInfo = new HeaderInfoResponse();
			headerInfo.parseJsonObj(response);
			setHeaderInfo(headerInfo);
			return false;
		}

		if (response.has(IDs.MY_SEND)) {
			setMy_send(response.optInt(IDs.MY_SEND));
		}
		if (response.has(IDs.REPLY_ME)) {
			setReply_me(response.optInt(IDs.REPLY_ME));
		}
		if (response.has(IDs.MY_REPLY)) {
			setMy_reply(response.optInt(IDs.MY_REPLY));
		}
		if (response.has(IDs.ALL_RETOPIC_COUNT)) {
			setAll_retopic_count(response.optInt(IDs.ALL_RETOPIC_COUNT));
		}
		return true;
	}

	public HeaderInfoResponse getHeaderInfo() {
		return headerInfo;
	}

	public void setHeaderInfo(HeaderInfoResponse headerInfo) {
		this.headerInfo = headerInfo;
	}

	public int getMy_send() {
		return my_send;
	}

	public void setMy_send(int my_send) {
		this.my_send = my_send;
	}

	public int getReply_me() {
		return reply_me;
	}

	public void setReply_me(int reply_me) {
		this.reply_me = reply_me;
	}

	public int getMy_reply() {
		return my_reply;
	}

	public void setMy_reply(int my_reply) {
		this.my_reply = my_reply;
	}

	public int getAll_retopic_count() {
		return all_retopic_count;
	}

	public void setAll_retopic_count(int all_retopic_count) {
		this.all_retopic_count = all_retopic_count;
	}

}
